<?php
/**
 *轮播图
 */

namespace app\api\model;


use app\common\model\Model;

class Banner extends Model
{
    const TABLE_NAME = 'banner';
    const CACHE_EXPIRE_LEVEL = self::CACHE_EXPIRE_LEVEL_1;
    const FIELDS = 'banner_id,title,banner_img,describe,type,forward_item';

    const BANNER_IMAGE_PATH='banner';
    protected $name = self::TABLE_NAME;

    public static function getBannerList(){


        $bannerList=self::commonQuery(self::TABLE_NAME)
                  ->field(self::FIELDS)->where('is_show',1)
                  ->select();

       return empty($bannerList)?[]:$bannerList;
    }
    public static function handleBannerList($list)
    {

        foreach ($list as $key=>$val)
        {
            $list[$key]['banner_img']=get_image_url(self::BANNER_IMAGE_PATH,$val['banner_img']);

        }
        return $list;
    }
}